package com.atguigu.scw.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * @author: mr.zhang
 * @description:
 * @create: 2020-11-04 10:50
 */

//listener还需要将自己注册到服务器中：将全类名配置到web.xml中
public class AppstartUpListener implements ServletContextListener {
//全局上下文对象监听器，实现项目路径的初始化
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        //上下文路径存储到application域中
        servletContextEvent.getServletContext().setAttribute("PATH",servletContextEvent.getServletContext().getContextPath());
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {

    }
}
